<?php 
include ("include/include.php.inc");
//include("connect_db.php");

html_header("Tickets");

list($status, $user) = auth_get_status();
$username=$user['username'];

/*   $backlink=getenv('HTTP_REFERER');*/

   if (empty($_POST['sup_no'])){
   	   echo"<center>Please Enter a Support name</center>";
	   die();
   }
   
   if (isset($_POST['sup_no'])) {
      $msup = $_POST['sup_no'];
      $result = mysql_query( "SELECT tic_no,tic_user,DATE_FORMAT(tic_date,'%d/%m/%y') AS mtic_date,tic_problem,tic_sup_name FROM chd_tickets WHERE tic_sup_name='$username' AND tic_status = 'O'") 
              or die("SELECT Error: ".mysql_error());
/*      $edit_row = mysql_fetch_array($result);
      if($edit_row['tic_sup_no']=="") {
            DIE("<center>Either the support# doesnot exists or there are no open tickets</center>");
      }

/*               if (FALSE === ($action = mysql_query($result)))
              {
                  print mysql_error()."<br />";
                  print $result;
              }*/
      }
				 $num_rows = mysql_num_rows($result);
				 
           		 print "<TABLE width=\"100%\" bgcolor=\"#336699\" BORDER=\"0\" bordercolor=\"#FFFFFF\"><tr>";
           		 print "<th width=\"11%\" scope=\"col\"><span class=\"style6\">Ticket#</span></th>";
		   		 print "<th width=\"22%\" scope=\"col\"><span class=\"style6\">User</span></th>";
		   		 print "<th width=\"10%\" scope=\"col\"><span class=\"style6\">Date</span></th>";
		   		 print "<th width=\"54%\" scope=\"col\"><span class=\"style6\">Problem</span></th>";
		   		 print "<th width=\"3%\" scope=\"col\">&nbsp;</th></tr>";

		    while ($row = mysql_fetch_assoc($result)){
                 extract($row);
		         print "<tr><th bgcolor=\"#FFFFFF\" scope=\"col\"><span class=\"style8\">$tic_no</span></th>";
                 print "<th bgcolor=\"#FFFFFF\" scope=\"col\"><div align=\"left\"><span class=\"style8\">$tic_user</span></div></th>";
                 print "<th bgcolor=\"#FFFFFF\" scope=\"col\"><span class=\"style8\">$mtic_date</span></th>";
                 print "<th bgcolor=\"#FFFFFF\" scope=\"col\"><div align=\"left\"><span class=\"style8\">$tic_problem</span></div></th>";
                 print "<th bgcolor=\"#FFFFFF\" scope=\"col\"><span class=\"style8\"><a href=\"close_tic.php?cmd=clo&tic_no=$tic_no\"><IMG src=\"css/images/close.gif\"></a></span></th></tr>";
                 }

                 print "</table>\n";
    print "<br>";print "<br>";

	
html_footer();
?>